package io.esirong.image.media;

import android.content.Intent;

import androidx.annotation.NonNull;
import io.esirong.image.media.target.Target;

/**
 * @ClassName: DefaultRequest
 * @Description: 具体请求
 * @author: huangrongcai
 * @date: 2022/9/4
 */
public class DefaultRequest implements Request {
    private Target target;

    public DefaultRequest(Target target) {
        if (target == null) {
            throw new IllegalArgumentException("The target can not be null.");
        }
        this.target = target;
    }

    @Override
    public Request mediaType(Media.TYPE type) {
        return this;
    }

    @NonNull
    @Override
    public Request callback(Object callback) {
        return this;
    }

    @Override
    public void start() {
        Intent intent = new Intent(target.getContext(), MediaActivity.class);
        intent.putExtra(MediaActivity.ARGS_TITLE, "TITLE");
        intent.putExtra(MediaActivity.ARGS_TYPE, Media.TYPE.IMAGE);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        target.startActivity(intent);
    }
}
